/**
 * Created by Administrator on 2017/8/22 0022.
 */


var hotcityFormatter = function(value,row,index){

    // return ['<a href="javascript:void(0)" class="altersorting">修改排名</a>'+'&nbsp&nbsp&nbsp'+'<a href="javascript:void(0)" class="editcity">编辑</a>'+'&nbsp&nbsp&nbsp'+'<a href="javascript:void(0)" class="deletecity">删除</a>'].join('');

    return ['<a href="javascript:void(0)" class="altersorting">修改排名</a>'+'&nbsp&nbsp&nbsp'+'<a href="javascript:void(0)" class="editcity">编辑</a>'+'&nbsp&nbsp&nbsp'].join('');
}


window.hotcityEvent={
    'click .altersorting':function(e, value, row, index){
        showModel("showOrderNum-div", function () {

            setRowToFrm("mergeOrderNum",row)
            $("#id").val(row.id);
        });
    },
    'click .deletecity':function(e, value, row, index){
        comment.showOperationTips("确定删除吗？", function () {
            comment.post("/web/city/delete", {id: row.id}, null, function (data) {
                if (data.res.code == 40000) {
                    // hint("删除成功");
                    comment.refresh();
                } else {
                    hint(data.res.msg);
                }
            });
        });
    },
    'click .editcity':function(e, value, row, index){
        showModel("showcityname-div", function () {
            setRowToFrm("mergeCityName",row)
            $("#cityId").val(row.id);
        });
    }
}

bindClick("button[data-event=merge-orderNum]", function () {
    var form = $("#mergeOrderNum");
    var sorting = $("#sorting");

    if (!isNumber(sorting)) {
        hint("请填入非负的正整数.");
        return false;
    }

    var params = form.formToArray();
    comment.post(form.attr("action"), params, null, function (data) {
        if (data.res.code == 40000) {
            closeModel("showOrderNum-div");
            var table = $("#table");
            table.bootstrapTable('refresh');
        } else {
            hint(data.res.msg);
        }
    });
});


bindClick("button[data-event=merge-cityname]", function () {
    var form = $("#mergeCityName");

    if($("#cityName").val()==""||$("#cityName").val().trim()==""){
        hint("城市名称必须填写");
        return false;
    }
    var params = form.formToArray();
    comment.post(form.attr("action"), params, null, function (data) {
        if (data.res.code == 40000) {
            closeModel("showcityname-div");
            var table = $("#table");
            table.bootstrapTable('refresh');
        } else {
            hint(data.res.msg);
        }
    });
});